package whf.framework.meta.entity;

import java.util.HashSet;
import java.util.Iterator;

import whf.framework.exception.PropertyException;

/**
 * Bo视图
 * @author wanghaifeng
 *
 */
public class View extends AbstractMeta<ViewProperty> implements whf.framework.meta.Form<ViewProperty> {
	private final static long serialVersionUID = 0;
	
	private Object referencedObject;
	
	private String validationName;

	// 定指表单属性
	// 标题
	private String title;
	
	private String queryString;

	//显示列数
	private int displayColumnCount = 2;

	// 可视级别
	private int visibleLevel;
	
	private int editableLevel;

	// 是否可编辑
	private boolean editable;
	
	// 主键风格
	private String pkStyle;
	
	// 是否主键作为后缀
	private boolean pkSuffix;
	
	// 表现风格
	private String displayStyle = "TABLE";
	
	// 内容列宽度
	private String displayCellWidth;
	
	// css后缀
	private String cssClassSuffix;
	
	// 
	private String navPosition;
	
	private int pageSize = 10;
	
	private boolean enablePreview = true;
	
	private boolean enableExportPdf = true;
	
	private boolean enableExportXls = true;
	
	private boolean enableCustomizeColumns = true;
	
	// 用于区分试图用途,例如工作流只读,工作流编辑表单等
	private String category;
	// 
	public View(){
		super();
	}
	
	public View(Object object) throws PropertyException{
		this();
		super.cloneProperties(object);
		this.setReferencedObject(object);
		super.setProperties(new HashSet<ViewProperty>());
		for(ObjectProperty prop: object.getProperties()){
			ObjectProperty p = (ObjectProperty)prop;
			ViewProperty vp = new ViewProperty(p);
			vp.setView(this);
			this.addProperty(vp);
		}
		this.setId(0);
	}
	
	public View(Object refObject, boolean initAllProperties){
		this.setReferencedObject(refObject);
		if(initAllProperties){
			for(Iterator it = refObject.getProperties().iterator(); it.hasNext();){
				ViewProperty property = (ViewProperty)it.next();
				super.addProperty(property);
			}
		}
	}

	public Object getReferencedObject() {
		return referencedObject;
	}

	public void setReferencedObject(Object boObject) {
		this.referencedObject = boObject;
	}

	public String getValidationName() {
		return validationName;
	}

	public void setValidationName(String validationName) {
		this.validationName = validationName;
	}
	//

	public String getCssClassSuffix() {
		return cssClassSuffix;
	}

	public void setCssClassSuffix(String cssClassSuffix) {
		this.cssClassSuffix = cssClassSuffix;
	}

	public String getDisplayCellWidth() {
		return displayCellWidth;
	}

	public void setDisplayCellWidth(String displayCellWidth) {
		this.displayCellWidth = displayCellWidth;
	}

	public int getDisplayColumnCount() {
		return displayColumnCount;
	}

	public void setDisplayColumnCount(int displayColumnCount) {
		this.displayColumnCount = displayColumnCount;
	}

	public String getDisplayStyle() {
		return displayStyle;
	}

	public void setDisplayStyle(String displayStyle) {
		this.displayStyle = displayStyle;
	}

	public boolean isEditable() {
		return editable;
	}

	public void setEditable(boolean editable) {
		this.editable = editable;
	}

	public boolean isEnableCustomizeColumns() {
		return enableCustomizeColumns;
	}

	public void setEnableCustomizeColumns(boolean enableCustomizeColumns) {
		this.enableCustomizeColumns = enableCustomizeColumns;
	}

	public boolean isEnableExportPdf() {
		return enableExportPdf;
	}

	public void setEnableExportPdf(boolean enableExportPdf) {
		this.enableExportPdf = enableExportPdf;
	}

	public boolean isEnableExportXls() {
		return enableExportXls;
	}

	public void setEnableExportXls(boolean enableExportXls) {
		this.enableExportXls = enableExportXls;
	}

	public boolean isEnablePreview() {
		return enablePreview;
	}

	public void setEnablePreview(boolean enablePreview) {
		this.enablePreview = enablePreview;
	}

	public String getPkStyle() {
		return pkStyle;
	}

	public void setPkStyle(String pkStyle) {
		this.pkStyle = pkStyle;
	}

	public boolean isPkSuffix() {
		return pkSuffix;
	}

	public void setPkSuffix(boolean pkSuffix) {
		this.pkSuffix = pkSuffix;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public int getVisibleLevel() {
		return visibleLevel;
	}

	public void setVisibleLevel(int visibleLevel) {
		this.visibleLevel = visibleLevel;
	}

	public int getEditableLevel() {
		return editableLevel;
	}

	public void setEditableLevel(int editableLevel) {
		this.editableLevel = editableLevel;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public String getNavPosition() {
		return navPosition;
	}

	public void setNavPosition(String navPosition) {
		this.navPosition = navPosition;
	}

	public String getQueryString() {
		return queryString;
	}

	public void setQueryString(String queryString) {
		this.queryString = queryString;
	}
}
